package acm.广东工业大学新生赛;

import java.util.*;

public class F {
    public static void main(String[] args) {
        TreeMap<Integer,Integer> map=new TreeMap<>();
        Scanner sc=new Scanner(System.in);
        int count = sc.nextInt();
        while (count-- > 0) {
            int n= sc.nextInt();;
            int v= sc.nextInt();;
            while (n-->0){
                int location = sc.nextInt();
                map.put(location,map.getOrDefault(location,0)+1);
            }
            Set<Map.Entry<Integer, Integer>> entries = map.entrySet();
            Map.Entry<Integer, Integer>[] arr=new Map.Entry[entries.size()];
            entries.toArray(arr);
            int min=Integer.MAX_VALUE;
            for (int i = 0; i < arr.length; i++) {
                int start=arr[i].getKey();
                int hurt=0;
                for (int j = 0; j < i; j++) {
                    hurt+=arr[j].getValue();
                }
                for (int j = i+1; j < arr.length; j++) {
                    if ((arr[j].getKey()-start-1)%v==0) {
                        start=arr[j].getKey();
                        continue;
                    }
                    hurt+=arr[j].getValue();
                }
                min=Math.min(min,hurt);
            }
            System.out.println(min);
        }
    }
}
